package com.qyhl.webtv.module_broke.scoop.itemview;

import com.google.gson.Gson;
import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.basiclib.utils.network.model.ApiResult;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.module_broke.common.BrokeUrl;

/**
 * Created by qyhl on 2017/12/12.
 */

public class ScoopItemModel implements ScoopItemContract.ScoopItemModel {
    private ScoopItemPresenter mPresenter;

    public ScoopItemModel(ScoopItemPresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    /**
     * 添加内容关注
     *
     * @param ID
     */
    @Override
    public void addAttention(String ID) {
        String userName = CommonUtils.getInstance().getUserName();

        EasyHttp.get(BrokeUrl.ADD_ATTENTION)
                .params("userName", userName)
                .params("borkeId", ID)
                .execute(new SimpleCallBack<String>() {
                    @Override
                    public void onError(ApiException e) {
                    }

                    @Override
                    public void onSuccess(String s) {
                        ApiResult apiResult = new Gson().fromJson(s,ApiResult.class);
                        if (apiResult.getCode() == 200) {
                        } else {
                        }
                    }
                });


    }

    /**
     * 取消内容关注
     *
     * @param ID
     */
    @Override
    public void cancelAttention(String ID) {
        String userName = CommonUtils.getInstance().getUserName();


        EasyHttp.get(BrokeUrl.CANCEL_ATTENTION)
                .params("userName", userName)
                .params("borkeId", ID)
                .execute(new SimpleCallBack<String>() {
                    @Override
                    public void onError(ApiException e) {
                    }

                    @Override
                    public void onSuccess(String s) {
                        ApiResult apiResult = new Gson().fromJson(s,ApiResult.class);
                        if (apiResult.getCode() == 200) {
                        } else {
                        }
                    }
                });

    }
}
